/**
 * 代号:隐无为 2017：厚溥
 * 文件名：RunApplication.java
 * 创建人：柯栋
 * 日期：2017年9月21日
 * 修改人：
 * 描述：
 */
package com.jh;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

/**
 * 用途：启动
 */
@SpringBootApplication
@EnableRedisHttpSession//session存储到session
@MapperScan(basePackages = "com.jh.dao")
@ComponentScan(basePackages={"org.kd","com.jh"}) 
@EnableScheduling
public class TopicRunApplication  extends SpringBootServletInitializer{
	@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(TopicRunApplication.class);
    }

	public static void main(String[] args) {
		long StartTime=System.currentTimeMillis();
		SpringApplication.run(TopicRunApplication.class, args);
		long EndTime=System.currentTimeMillis();
		long time=EndTime-StartTime;
		System.err.println("ANSWER-启动成功,时间:"+time+"ms");
	} 
	
	 /**
	 *  @功能:控制session时长
	 *  @作者:jh @代号:甲骨兽进化
	 *  @时间:2018年5月5日
	 *  @return  
	 */
	@Bean
	 public EmbeddedServletContainerCustomizer containerCustomizer(){
	        return new EmbeddedServletContainerCustomizer() {
	            @Override
	            public void customize(ConfigurableEmbeddedServletContainer container) {
	                 container.setSessionTimeout(1800);//单位为S
	           }
	     };
	 }
}
